const options = {
  code: 0,
  msg: 'success',
};

const getFileDirectory = (req, res) => {
  const result = [];
  const randomNum = Math.ceil(Math.random() * 10) + 1;
  for (let i = 1; i < randomNum; i++) {
    result.push({
      name: `文件名称${i}`,
      isDirectory: Math.random() > .5,
    });
  }
  return res.json({
    ...options,
    data: {
      items: result,
      isComplete: Math.random() > .5,
    }
  });
};

const getFile = (req, res) => {
  const { path } = req.query;
  return res.json({
    ...options,
    data: {
      name: `${path}.jpg`,
      createdAt: Date.now(),
      size: 1024 * 1024 * 13,
      imgUrl: Math.random() > .5 ? 'http://linxunzyf.cn/img/avatar.jpg' : 'https://123.60.231.101:80/imgproxy/9JulAgskJBYjCToAUqlCM7Agm5qCUMszkBrgc1ebPkI//bG9jYWw6Ly8vZGF0YXNldC9pcGMvMjAyMTA4MTIxMS9yZXFzX3VuZXRwcC15dF8xNjI4NzM4MTM1LmpwZw',
    }
  });
};

const fileInfo ={
  ...options,
  data: {
    name: '图片名称.jpg',
    createdAt: Date.now(),
    size: 1024 * 1024 * 13,
    imgUrl: 'http://linxunzyf.cn/img/avatar.jpg',
  }
}

export default {
  'GET /adhub/api/v1/datasets/:id/file-directory': getFileDirectory,
  'GET /adhub/api/v1/datasets/:id/file-directory/file': getFile,
}